package com.efast.dmom.mgmt.controller.mes;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.efast.cafe.framework.bean.ResultBean;
import com.efast.dmom.mgmt.bean.mes.MesWorkCalendar;
import com.efast.dmom.mgmt.service.mes.MesWorkCalendarService;

@Controller
@RequestMapping("/workCanlendar")
public class MesWorkCalendarController {

	@Autowired
	private MesWorkCalendarService mesWorkCalendarService;

	// 查询所有车间信息
	@RequestMapping("/workshop")
	public @ResponseBody ResultBean getAllworkShop(@RequestBody Map<String,Object> map) {
		ResultBean allworkShop = mesWorkCalendarService.getAllworkShop(map);
		return allworkShop;
	}

	// 
	// 查询指定月份的所有工作日历中的数据
	@RequestMapping("/monthWorkCanlendar")
	public @ResponseBody ResultBean getworkCanlendarByMonth(@RequestBody Map<String,Object> map) {
		 ResultBean getworkCanlendarByMonth = mesWorkCalendarService.getworkCanlendarByMonth(map);
		return getworkCanlendarByMonth;
	}

	
	// 通过日历时间批量新增对应的班次
	@RequestMapping("/addShiftByWorkCanlendars")
	public @ResponseBody ResultBean addShiftByWorkCanlendars(@RequestBody MesWorkCalendar mesWorkCalendar) {
		List<String> calendarDate = mesWorkCalendar.getCalendarDateList();
		ResultBean addShiftByWorkCanlendars = mesWorkCalendarService.addShiftByWorkCanlendars(calendarDate,
				mesWorkCalendar);
		return addShiftByWorkCanlendars;
	}

	// 
	// 更新节拍等数据
	@RequestMapping("/updateWorkCanlendar")
	public @ResponseBody ResultBean updateWorkCanlendar(@RequestBody MesWorkCalendar mesWorkCalendar) {
		ResultBean updateWorkCanlendar = mesWorkCalendarService.updateWorkCanlendar(mesWorkCalendar);
		return updateWorkCanlendar;
	}

	
	
	// 
	// 批量删除某时间下的班次信息
	@RequestMapping("/deleteShiftByCanlendar")
	public @ResponseBody ResultBean deleteShiftByCanlendar(@RequestBody Map<String,Object> map) {
		ResultBean deleteShiftByCanlendar = mesWorkCalendarService.deleteShiftByCanlendar(map);
		return deleteShiftByCanlendar;
	}

	// 
	// 通过班次的id查询对应的班次详情信息
	@RequestMapping("/selectShiftDetailByShiftId")
	public @ResponseBody ResultBean selectShiftDetailByShiftId(@RequestBody MesWorkCalendar mesWorkCalendar) {
		ResultBean selectShiftDetailByShiftId = mesWorkCalendarService.selectShiftDetailByShiftId(mesWorkCalendar);
		return selectShiftDetailByShiftId;
	}

	// 
	// 更新指定日历日期为工作日还是休息日
	@RequestMapping("/updateIfwork")
	public @ResponseBody ResultBean updateIfwork(@RequestBody Map<String,Object> map) {
		ResultBean updateIfwork = mesWorkCalendarService.updateIfwork(map);
		return updateIfwork;
	}
	
	// 通过当前日历时间查询班次信息
		@RequestMapping("/selectShiftIdByCanlendar")
		public @ResponseBody ResultBean selectShiftIdByCanlendar(@RequestBody Map<String,Object> map) {
			ResultBean updateIfwork = mesWorkCalendarService.selectShiftIdByCanlendar(map);
			return updateIfwork;
		}
		
		
	// 查询配置的所有工厂
		@RequestMapping("/queryAllPlant")
		public @ResponseBody ResultBean queryAllPlant() {
			ResultBean queryAllPlant = mesWorkCalendarService.queryAllPlant();
			return queryAllPlant;
		}
		
	// 查询工作日历中需要显示的数据
		@RequestMapping("/selectCalendarSuspendDate")
		public @ResponseBody ResultBean selectCalendarSuspendDate(@RequestBody Map<String,Object> map) {
			ResultBean selectCalendarSuspendDate = mesWorkCalendarService.selectCalendarSuspendDate(map);
			return selectCalendarSuspendDate;
		}
		
}
